<template>
  <div class="island-manage">

    <div class="main">
      <div class="user-rising">
        用户增长趋势图
      </div>

      <div class="today-data">

        <div class="today-data-item">
          今日用户增长
        </div>

        <div class="today-data-item">
          今日活跃数值
        </div>

      </div>

      <div class="todolist">
        近期待办
      </div>

    </div>

    <div class="right">

<!--      <div class="cover">-->
<!--        <img :src="courseInfo.cover">-->
<!--      </div>-->

      <div class="date">
        {{ questionInfo.name }}
      </div>

      <div class="description">
        {{ questionInfo.description }}
      </div>

<!--      <div class="chooses">-->
<!--        <div class="choose" @click="changeStatus" :class="this.status === 0 ? 'on' : ''">目录</div>-->
<!--        <div class="choose" @click="changeStatus" :class="this.status === 1 ? 'on' : ''">思考</div>-->
<!--      </div>-->

<!--      <div class="keys">-->

<!--      </div>-->

      <div class="mini-mind-input">
        <MarkdownInput :type="'mini'" @SendMind="addNote" :value="noteInput"></MarkdownInput>
      </div>

    </div>
  </div>
</template>

<script>
import {client} from "@/utils/oss.js";
import WangEditor from "@/components/WangEditor.vue";
import MarkdownInput from "@/components/MarkdownInput.vue";

export default {
  components: {WangEditor, MarkdownInput},
  data() {
    return {
      questionInfo: {},
      status: 0,
    }
  },
  mounted() {
    if (this.$route.params && this.$route.params.id) {
      this.questionInfo.id = "1601204397644980225"
      this.getCourseInfo()
    }
  },
  methods: {
    getCourseInfo() {
      this.$api.getCourseInfo({courseId: this.questionInfo.id})
          .then(res => {
            this.questionInfo = res.data
          })
    },
    changeStatus() {
      this.status = this.status === 0 ? 1 : 0
    },


    setIntroduction: function (html) {
      this.questionInfo.introduction = html;//在父组件修改值
    },
    saveCourse() {
      let that = this
      this.$confirm('是否确认添加课程信息', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.course.cover = this.courseCover
        this.course.background = this.courseBackground
        this.course.status = 0
        this.$api.saveCourse(this.course)
            .then(response => {
              this.$message({
                type: 'success',
                message: '添加成功!'
              })
              that.$router.push({
                name: 'course-edit',
                params:
                    {
                      courseId: response.data
                    }
              })
            })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消添加'
        });
      });
    },
    handleAvatarSuccess(res, file) {
      console.log(res, file)
    },
    beforeAvatarUpload(file) {
      client()
          .multipartUpload(file.name || Date.now().toString(), file)
          .then((result) => {
            let url = result.res.requestUrls[0];
            this.courseCover = url.split("?upload")[0]
          });
    },
    beforeBackgroundUpload(file) {
      client()
          .multipartUpload(file.name || Date.now().toString(), file)
          .then((result) => {
            let url = result.res.requestUrls[0];
            this.courseBackground = url.split("?upload")[0]
          });

    }
  }
}
</script>

<style scoped lang="scss">

.island-manage {
  width: 1120px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;

  .main {
    width: 800px;
    height: 1200px;

    .user-rising{
      width: 100%;
      height: 300px;
      background-color: #dadada;
      border-radius: 10px;
    }

    .today-data{
      width: 800px;
      margin-top: 20px;
      display: flex;
      flex-direction: row;
      justify-content: space-between;

      .today-data-item{
        width: 390px;
        height: 100px;
        background-color: #dadada;
        border-radius: 10px;
      }
    }

    .todolist{
      margin-top: 20px;
      width: 100%;
      height: 300px;
      background-color: #dadada;
      border-radius: 10px;
    }

  }

  .right {
    width: 300px;
    height: 700px;
    position: sticky;
    top: 100px;

    display: flex;
    flex-direction: column;

    .cover {
      width: 300px;
      height: 200px;
      border-radius: 10px;
      overflow: hidden;
    }

    .date {
      font-size: 30px;
      font-weight: bold;
      font-style: italic;
    }

    .description {
      margin-top: 10px;
    }

    .chooses {
      display: flex;
      flex-direction: row;
      margin-top: 10px;
      margin-bottom: 5px;

      .choose {
        padding: 3px 6px;
        margin-right: 5px;
      }

      .choose:hover {
        cursor: pointer;
      }

      .on {
        border: solid thin #414141;
        border-radius: 5px
      }
    }

    .keys {
      margin-top: 10px;
      width: 300px;
      height: 300px;
      padding: 0;
      border: solid #575757;
      border-radius: 5px;

      overflow-y: scroll;
      overflow-x: hidden;


    }
  }

  .mini-mind-input {
    margin-top: 20px;
    min-height: 120px;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 5px;
  }


  img {
    width: 100%;
    height: 100%;
  }

}


.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
